// import { FC } from "react";
import QTitle from "./QTitle";
import QInput from "./QInput";

import { InputDefaultProps, InputPropsType, QInputType } from "./QInput/interface";
import { TitleDefaultProps, TitlePropsType, QTitleType } from "./QTitle/interface";

export type ComponentType = typeof QTitle | typeof QInput;

export type ComponentPropsType = InputPropsType & TitlePropsType;
export type ComponentPropsOrType = InputPropsType | TitlePropsType;

export type ComponentConfType<T extends ComponentType> = {
  title: string;
  type: string;
  Component: T;
  defaultProps: React.ComponentProps<T>;
};

const componentConf: ComponentConfType<ComponentType>[] = [
  {
    title: "标题",
    type: QTitleType,
    Component: QTitle,
    defaultProps: TitleDefaultProps,
  },
  {
    title: "输入框",
    type: QInputType,
    Component: QInput,
    defaultProps: InputDefaultProps,
  },
];

export function getComponentConfByType(type: string) {
  return componentConf.find((conf) => conf.type === type);
}
